home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / latex209 / contrib / misc / hangcaption.sty < prev    next >
Text File  |  1992-08-31  |  5KB  |  114 lines

  1. %%% ====================================================================
  2. %%%  @LaTeX-style-file{
  3. %%%     filename        = "hangcaption.sty",
  4. %%%     version         = "2.00",
  5. %%%     date            = "27 August 1992",
  6. %%%     time            = "22:23:46 EDT",
  7. %%%     author          = "David M. Jones",
  8. %%%     address         = "MIT Laboratory for Computer Science
  9. %%%                        Room NE43-316
  10. %%%                        545 Technology Square
  11. %%%                        Cambridge, MA 02139
  12. %%%                        USA",
  13. %%%     telephone       = "(617) 253-5936",
  14. %%%     FAX             = "(617) 253-3480",
  15. %%%     checksum        = "57880 113 520 5319",
  16. %%%     email           = "dmjones@theory.lcs.mit.edu",
  17. %%%     codetable       = "ISO/ASCII",
  18. %%%     keywords        = "LaTeX, caption",
  19. %%%     supported       = "no",
  20. %%%     abstract        = "Defines a variant of the caption command to
  21. %%%                        produce captions with hanging
  22. %%%                        indentation.",
  23. %%%     docstring       = "This is the debugged version of a modified
  24. %%%                        caption macro, \hangcaption, to produce
  25. %%%                        captions with hanging indentation, like
  26. %%%                        this:
  27. %%%
  28. %%%                        Figure 1.1: XXXXX XXX XXXX XXXX XXX
  29. %%%                                    XXX XXX XXX XXX XX XXX
  30. %%%
  31. %%%                        The length variable \captionwidth controls
  32. %%%                        how the caption is typeset.  If the width
  33. %%%                        of the caption is less than \captionwidth,
  34. %%%                        the \hangcaption is typeset the same way a
  35. %%%                        short \caption would be (usually centered).
  36. %%%                        Otherwise, it is set as shown above, with a
  37. %%%                        total width equal to \captionwidth.
  38. %%%                        \captionwidth is set to \hsize normally,
  39. %%%                        but you may want to change it temporarily
  40. %%%                        to match the width of a \tabular*
  41. %%%                        environment, for example.
  42. %%%
  43. %%%                        \hangcaption is used in the same way as
  44. %%%                        \caption.  To retain compatibility with
  45. %%%                        previous versions of this style, the
  46. %%%                        \hangcaption is also available under the
  47. %%%                        name \isucaption.
  48. %%%
  49. %%%                        I did not write this file.  The original
  50. %%%                        author is unknown.  However, I did fix a bug,
  51. %%%                        namely, I removed a superflous "^^" that was
  52. %%%                        causing one of the close braces to be
  53. %%%                        interpreted as an equals sign, thus messing
  54. %%%                        up the brace balancing.  I also tacked an
  55. %%%                        "\endinput" on to the end of the file and
  56. %%%                        added this header, and incorporated a few
  57. %%%                        changes suggested by Harm Bakker, George
  58. %%%                        Greenwade, and Rainer Schoepf.
  59. %%%
  60. %%%                        v2.00 (27 Aug 1992): altered \numberline to
  61. %%%                        use \the... instead of \fnum@... (fix due to
  62. %%%                        Harm Bakker <bakker@cs.rulimburg.nl>).
  63. %%%                        Changed \isucaption to \hangcaption at George
  64. %%%                        Greenwade's <bed_gdg@SHSU.edu> suggestion.
  65. %%%
  66. %%%                        v1.03 (12 August 1992): minor changes to
  67. %%%                        header.
  68. %%%
  69. %%%                        v1.02 (12 August 1992): patches by Rainer
  70. %%%                        Schoepf <schoepf@sc.ZIB-Berlin.DE> to (a)
  71. %%%                        work around a bug in LaTeX and (b) measure
  72. %%%                        the caption correctly by including room for
  73. %%%                        the colon and the space.
  74. %%%
  75. %%%                        The checksum field above contains a CRC-16
  76. %%%                        checksum as the first value, followed by the
  77. %%%                        equivalent of the standard UNIX wc (word
  78. %%%                        count) utility output of lines, words, and
  79. %%%                        characters.  This is produced by Robert
  80. %%%                        Solovay's checksum utility.",
  81. %%%  }
  82. %%% ====================================================================
  83.  
  84. \newlength\captionwidth \captionwidth=\hsize
  85.  
  86. \def\hangcaption{\refstepcounter\@captype\@dblarg{\@hangcaption\@captype}}
  87.  
  88. \long\def\@hangcaption#1[#2]#3{%
  89.   \baselineskip 14.5\p@
  90.   \addcontentsline{\csname ext@#1\endcsname}{#1}%
  91.     {\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
  92.   \par
  93.   \begingroup
  94.     \@parboxrestore
  95.     \setbox\@tempboxa\hbox{\csname fnum@#1\endcsname: #3}%
  96.     \ifdim \wd\@tempboxa > \captionwidth
  97.       \begingroup
  98.         \setbox\@tempboxa\hbox{\csname fnum@#1\endcsname: }%
  99.         \advance \captionwidth by -\wd\@tempboxa
  100.         \@makecaption{\csname fnum@#1\endcsname}%
  101.             {\ignorespaces{\protect\parbox[t]{\captionwidth}{\leavevmode#3}}}%
  102.       \endgroup
  103.     \else
  104.       \begingroup
  105.         \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}%
  106.       \endgroup
  107.     \fi
  108.     \par\vspace{1.7ex}%
  109.   \endgroup}
  110.  
  111. \let\isucaption\hangcaption
  112.  
  113. \endinput
  114.